*creation of legitimacy perception index
gen legit1 = q11
gen legit2 = q12
gen legit3 = q13
recode legit3 1=5 2=4 4=2 5=1
gen legit4 = q14
recode legit4 1=5 2=4 4=2 5=1

gen legittot = legit1+legit2+legit3+legit4

*coding decision-making perception items and creation of decision-making perception index
gen polit1 = q15
recode polit1 1=5 2=4 4=2 5=1
gen polit2 = q16
recode polit2 1=5 2=4 4=2 5=1
gen unfair = q17
gen unprincipled = q18

gen dmshort = polit1+polit2+unprincipled

gen trust = q19
recode trust 1=5 2=4 4=2 5=1

*Creation of acceptance index
gen accept1 = q23
recode accept1 2=-1
recode accept1 -1=0 if q24b==4
recode accept1 -1=-2 if q24b==2
recode accept1 -1=-3 if q24b==1
recode accept1 min/max =. if q24b==.&q23==2

recode accept1 1=2 if q24a==3
recode accept1 1=3 if q24a==2
recode accept1 1=4 if q24a==1
recode accept1 min/max =. if q24a==.&q23==1

gen accept2 = q25a
replace accept2 = q25b if accept2==.

gen accept3 = q26

replace accept1 = (accept1+3)/7
replace accept2 = (accept2-1)/6
replace accept3 = (accept3-1)/3

gen acptot = accept1+accept2+accept3

*Creation of variables measuring pre- and post-decision issue position on juvenile life sentence
gen strpre = q9a
replace strpre = q9b if q9a==.
recode strpre 1=4 2=3 3=2 4=1

gen preiss = q8
recode preiss 2=-1
replace preiss = preiss*strpre
recode preiss -4=-3 -3=-2 -2=-1 -1=0


gen poststr = q28a
replace poststr = q28b if q28a==.
recode poststr 1=4 2=3 3=2 4=1

gen postiss = q27
recode postiss 2=-1
replace postiss = postiss*poststr
recode postiss -4=-3 -3=-2 -2=-1 -1=0

*creation of issue position change variable
gen isschange = postiss-preiss if preiss>0
replace isschange = -(postiss-preiss) if preiss<1
replace isschange = -isschange

*Creation of variable measuring perceived importance of issue
gen imp = q10
recode imp 1=4 2=3 3=2 4=1

*creation of court awareness variable
gen aware1 = q5
gen aware2 = q6

recode aware1 1=4 2=3 3=2 4=1
recode aware2 1=6 2=5 3=4 4=3 5=2 6=1

gen a101 = (aware1-1)/3
gen a201 = (aware2-1)/5

gen awaretot = a101+a201

*creation of election fairness index
gen elect1 = q1
gen elect2 = q2

recode elect1 1=5 2=4 4=2 5=1

gen electtot = elect1+elect2

*creation of rule of law index
gen rlaw1 = q3
gen rlaw2 = q4

gen rlawtot = rlaw1+rlaw2

*creation of specific support index
gen ideodiff = q20
recode ideodiff 3=2 2=1 1=0 4=1 5=0

gen job = q21
recode job 4=0 3=1 2=2 1=3

gen ideodiff01 = ideodiff/2
gen job01 = job/3
gen output01 = (job01+ideodiff01)/2

*creation of supreme court favorability variable
gen favor = q22

*creation of gender variable
gen female = gender
recode female 2=1 1=0

*creation of race indicator variables
gen black = race
recode black 1=0 2=1 3/max=0

gen hispanic = race
recode hispanic 1/2=0 3=1 4/max=0

gen other = race
recode other 1/3=0 4/max=1
gen otherrace = other

*creation of variable identifying the ideological direction of the court decision - - 1= conservative decision, 0=liberal decision
gen libdecision = q8
recode libdecision 1=0 2=1

*transforming all variables into variable that range from to 0 to 1
gen legit01 = (legittot-4)/16
gen acptot01 = acptot/3
gen elect01 = (electtot-2)/8
gen rlaw01 = (rlawtot-2)/8
gen aware01 = awaretot/2
gen strpre01 = (strpre-1)/3
gen educ01 = (educ-1)/5
gen imp01 = (imp-1)/3
gen favor01 = (favor-1)/99
gen postatt01 = (postatt+3)/7

*creation of variable measuring whether the respondent thought their state used elections to select judges
gen electknow = q7
recode electknow 2=0

*creation of decisional ideological conflict variable
gen ideo01 = ideo5
recode ideo01 6=. 
replace ideo01 = (ideo01-1)/4

gen ideoconflict = ideo5
recode ideoconflict 6=.
gen ideotemp = ideo5
recode ideotemp 6=.
replace ideoconflict = -ideotemp+6 if libdecision==0
gen ideoconflict01 = (ideoconflict-1)/4
replace ideoconflict01 = abs(ideoconflict01-1)

*creation of four-level issue position change variable
gen isschange4 = isschange
recode isschange4 min/-1=-1 2/max=2

*mean centering all variables
gen output01mean = output01 -  .6213452
gen legit01mean = legit01 - .6134228
gen rlaw01mean = rlaw01 -  .6614464
gen imp01mean = imp01 - .4134754
gen aware01mean = aware01 - .5706284 
gen libdecisionmean = libdecision - .370882
gen femalemean = female - .4968309
gen educ01mean = educ01 - .4790211
gen blackmean = black -  .1102599 
gen hispanicmean = hispanic -  .0678789
gen otherracemean = otherrace - .0509407 
gen partisanmean = partisan - .1831851 
gen nonpartisanmean = nonpartisan -  .3256452
gen retentionmean = retention - .2440709 
gen strpre01mean = strpre01 - .6179113 
gen ideo01mean = ideo01 - .5406505
gen isschangemean = isschange- .393717
gen ideoconflict01mean = ideoconflict01-.5639095

*Creating variables with varying 0 points to use in models below calculating predicted values	  
gen output16 = output01- .1666667
gen output25 = output01- .25
gen output33 = output01- .3333333
gen output42 = output01- .4166667 
gen output5 = output01- .5 
gen output58 = output01- .5833334 
gen output66 = output01- .6666667
gen output75 = output01- .75 
gen output83 = output01- .8333334

gen legit25 = legit01-.25
gen legit37 = legit01-.375 
gen legit5 = legit01-.5
gen legit62 = legit01- .625
gen legit75 = legit01- .75 
gen legit87 = legit01- .875
gen legitrev= legit01- 1

*models for columns 3 and 4 of Table 1
xtmixed isschange output01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)

*alpha for legitimacy items
alpha legit1 legit2 legit3 legit4 if q33==6&aware1>1

*correllation between two aspects of specific support
corr ideodiff01 job01 if q33==6&aware1>1

*correllation between legitimacy perceptions and specific support
corr legit01 output01 if q33==6&aware1>1

*alpha for acceptance items
alpha accept1 accept2 accept3 if q33==6&aware1>1

*correlation between acceptance and issue position change
corr isschange acptot01

*calculating the distribution for the issue position change
tab isschange if q33==6&aware1>1 [iweight=weight]

*calculating the percentage of people who switched the direction of their position on the juvenile life sentence
gen issswitch = 0
recode issswitch 0=1 if q8~=q27
recode issswitch 0=. 1=. if q8==.|q27==.
tab issswitch if q33==6&aware1>1 [iweight=weight]

*models for columns 1 and 2 of the appendix table 2
xtmixed isschange output01 c.legit01 c.output01##c.partisan c.output01##c.nonpartisan c.output01##c.retention  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01 c.legit01##c.partisan c.legit01##c.nonpartisan c.legit01##c.retention  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)


*The models below were used to calculate the predicted values of issue position change and the confidence intervals used in the middle panel of Figure 1. The constant in the models
*below is the predicted value of issue position change when all other varibles are held at zero. By mean-centering every other variable and changing the coding of the output01 variable,
*the predicted value holding all other variables at their means and the associated confidence intervals can be calculated for various points along the specific support variable.

xtmixed isschange output01 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output16 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output25 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output33 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output42 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output5 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output58 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output66 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output75 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange output83 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)


*The models below were used to calculate the predicted values acceptance and the confidence intervals used in the data analysis section. The constant in the models
*below is the predicted value of acceptance when all other varibles are held at zero. By mean-centering every other variable and changing the coding of the output01 variable,
*the constant and its associated confidence intervals can be calculated for various points along the specific support variable.

xtmixed acptot01 output01 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output16 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output25 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output33 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output42 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output5 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output58 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output66 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output75 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output83 legit01mean  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)

xtmixed acptot01 output01mean legit25  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legit37  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legit5  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legit62  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legit75  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legit87  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 output01mean legitrev  rlaw01mean  imp01mean  aware01mean  libdecisionmean  femalemean  educ01mean blackmean  hispanicmean otherracemean   partisanmean  nonpartisanmean retentionmean  strpre01mean ideoconflict01mean if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)


*model from footnote 5 in which the issue position change variable is recoded into a four-level ordinal variable
meoprobit isschange4 output01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1

*model from footnote 7 in which the issue positin strength variable is excluded from the model.
xtmixed isschange output01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)

*model from footnote 8 in which the issue position change variable is added as an independent variable in the acceptance model
xtmixed acptot01 isschange output01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)

*models from footnote 9 discussing when the individual component of specific support replaces the specific support index 
xtmixed acptot01 job01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed acptot01 ideodiff01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange ideodiff01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)
xtmixed isschange job01 legit01  rlaw01  imp01  aware01  libdecision  female  educ01 black  hispanic otherrace   partisan  nonpartisan retention  strpre01 ideoconflict01 if q33==6&aware1>1 [pweight=weight]  || inputstate:, pwscale(size)

